
import java.util.Scanner;

/**
 * @author Difan Zhao
 */


public class BuildMass implements Build {
    private Mass myNewMass;
    /**
     * build the object.
     * @param line is a scanner that receives user input
     * @param sim is the simulation where object is created
     *        create material object according to user input
     */

    @Override
    public final void build(Scanner line, Simulation sim) {
        int id = line.nextInt();
        double x = line.nextDouble();
        double y = line.nextDouble();
        double mass = line.nextDouble();
        if (mass < 0) {
            myNewMass = new FixedMass(id, x, y, mass);
        }
        else {
            myNewMass = new Mass(id, x, y, mass);
        }

        sim.add(myNewMass);
    }
}
